package com.lxr0860.lxr0860production_test.utils;

import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.lxr0860.lxr0860production_test.R;
import com.lxr0860.lxr0860production_test.base.App;


/**
 * Created by uniriho on 2017/4/14.
 */

public class ToastUtils {
    private static Toast toast = null;

    public static void showMessage(String showMessage) {
        if (toast == null) {
            toast = new Toast(App.getContext());
        }
        showTextToast(showMessage);
    }


    /**
     * 描述:[显示文本的Toast]
     *
     * @param message
     * @author: LXR
     * @Date: 2023/6/29 16:54
     * @Return: void
     */
    public static void showTextToast(String message) {
        Toast toast = new Toast(App.getContext());
        View toastview = LayoutInflater.from(App.getContext()).inflate(R.layout.layout_toast, null);
        TextView text = toastview.findViewById(R.id.tv_toast_message);
        text.setText(message);
        toast.setGravity(Gravity.CENTER, 0, -100);
        toast.setDuration(Toast.LENGTH_SHORT);
        toast.setView(toastview);
        toast.show();
    }
}
